{{#if hasSelection}}
  <div id='selected-controls'>
    <button {{action "approveUsers"}} class='btn'>{{count-i18n key="admin.users.approved_selected" count=selectedCount}}</button>
    <button {{action "rejectUsers"}}  class='btn btn-danger'>{{count-i18n key="admin.users.reject_selected" count=selectedCount}}</button>
  </div>
{{/if}}

<div class="admin-title">
  <div class="pull-left">
    <h2>{{title}}</h2>
  </div>
</div>
<div class='username controls'>
  {{text-field value=listFilter placeholder=searchHint}}
  {{#unless showEmails}}
    <div class="pull-right">
      <button {{action "showEmails"}} class="btn">{{i18n 'admin.users.show_emails'}}</button>
    </div>
  {{/unless}}
</div>

{{#conditional-loading-spinner condition=refreshing}}
  {{#if model}}
    <table class='table users-list'>
      <tr>
        {{#if showApproval}}
          <th>{{input type="checkbox" checked=selectAll}}</th>
        {{/if}}
        <th>&nbsp;</th>
        <th>{{i18n 'username'}}</th>
        <th>{{i18n 'email'}}</th>
        <th>{{i18n 'admin.users.last_emailed'}}</th>
        <th>{{i18n 'last_seen'}}</th>
        <th>{{i18n 'admin.user.topics_entered'}}</th>
        <th>{{i18n 'admin.user.posts_read_count'}}</th>
        <th>{{i18n 'admin.user.time_read'}}</th>
        <th>{{i18n 'created'}}</th>
        {{#if showApproval}}
          <th>{{i18n 'admin.users.approved'}}</th>
        {{/if}}
        <th>&nbsp;</th>
      </tr>

      {{#each model as |user|}}
        <tr class="user {{user.selected}} {{unless user.active 'not-activated'}}">
          {{#if showApproval}}
            <td>
              {{#if user.can_approve}}
                {{input type="checkbox" checked=user.selected}}
              {{/if}}
            </td>
          {{/if}}
          <td><a href="{{unbound user.path}}" data-user-card="{{unbound user.username}}">{{avatar user imageSize="small"}}</a></td>
          <td>{{#link-to 'adminUser' user}}{{unbound user.username}}{{/link-to}}</td>
          <td class='email'>{{unbound user.email}}</td>
          <td>{{{unbound user.last_emailed_age}}}</td>
          <td>{{{unbound user.last_seen_age}}}</td>
          <td>{{number user.topics_entered}}</td>
          <td>{{number user.posts_read_count}}</td>
          <td>{{{unbound user.time_read}}}</td>

          <td>{{{unbound user.created_at_age}}}</td>

          {{#if showApproval}}
          <td>
            {{#if user.approved}}
              {{i18n 'yes_value'}}
            {{else}}
              {{i18n 'no_value'}}
            {{/if}}
          </td>
          {{/if}}
          <td>
            {{#if user.admin}}<i class="fa fa-shield" title="{{i18n 'admin.title'}}"></i>{{/if}}
            {{#if user.moderator}}<i class="fa fa-shield" title="{{i18n 'admin.moderator'}}"></i>{{/if}}
          </td>
        </tr>
      {{/each}}

    </table>
  {{else}}
    <p>{{i18n 'search.no_results'}}</p>
  {{/if}}
{{/conditional-loading-spinner}}
